Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ramp_convert .py to .xlsx files to command line #131

Merged
merged 10 commits into from
May 15, 2024

Conversation

Bachibouzouk
Copy link
Collaborator

@Bachibouzouk Bachibouzouk commented Apr 15, 2024

This should fix #130

On linux it works. @Stevogallo - could you try on windows?

In a new virtual env, install this ramp version by checking out this branch and then form the root of the repository you type pip install -e .

To test if it works I suggest you move then within your terminal to a different folder where you copy-paste a .py file, then you should be able to convert it to excel using in the command line
ramp_convert -i <name of your .py ramp input file>

Alternatively, you should be able to do it from within a python script:

from ramp import ramp_py2xlsx

ramp_py2xlsx(fname_path="<name of your .py ramp input file>")

@FLomb FLomb added the bug Something isn't working label Apr 25, 2024
@FLomb
Copy link
Contributor

FLomb commented Apr 25, 2024

I've added @ClaudiaLSS and @mohammadamint because I believe they may also be on Windows or a non-Linux system and may help test this.

@ClaudiaLSS
Copy link
Collaborator

Hey @FLomb, I've been working on Linux, and it seems to be working fine for me. I'm not sure if I'll be able to test this.

@Bachibouzouk
Copy link
Collaborator Author

We still need a windows user to tell us if it works, then I will update the documentation with this new command

@FLomb
Copy link
Contributor

FLomb commented May 1, 2024

Perhaps @FraSanvit could make a test on Windows

@Bachibouzouk Bachibouzouk force-pushed the fix/convert-old-excel-files branch from 6609e49 to 673d5d1 Compare May 7, 2024 16:24
@mohammadamint
Copy link
Collaborator

I've added @ClaudiaLSS and @mohammadamint because I believe they may also be on Windows or a non-Linux system and may help test this.

I have some issues running it (get some errors), not sure if it is the correct way or not:

from ramp import ramp_py2xlsx

ramp_py2xlsx(
    "ramp/example/input_file_1.py", # using the example files in ramp
    output_path="test.xlsx"
)


---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File c:\Users\TAHAVORM\Downloads\GitRepos\RAMP\amin_test.py:2
      [1](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/amin_test.py:1) # %%
----> [2](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/amin_test.py:2) ramp_py2xlsx(
      [3](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/amin_test.py:3)     "ramp/example/input_file_1.py",
      [4](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/amin_test.py:4)     output_path="test.xslx"
      [5](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/amin_test.py:5) )

File c:\Users\TAHAVORM\Downloads\GitRepos\RAMP\ramp\ramp_convert_old_input_files.py:84, in convert_old_user_input_file(fname_path, output_path, suffix, keep_names)
     [81](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/ramp/ramp_convert_old_input_files.py:81) output_fname = fname_path.split(os.path.sep)[-1].replace(".py", suffix)
     [82](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/ramp/ramp_convert_old_input_files.py:82) output_fname = os.path.join(output_path, output_fname)
---> [84](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/ramp/ramp_convert_old_input_files.py:84) file_module = importlib.import_module(fname)
     [86](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/ramp/ramp_convert_old_input_files.py:86) user_list = file_module.User_list
     [88](file:///C:/Users/TAHAVORM/Downloads/GitRepos/RAMP/ramp/ramp_convert_old_input_files.py:88) UseCase(users=user_list).save(output_fname)

File c:\Users\TAHAVORM\AppData\Local\miniconda3\envs\ramp\lib\importlib\__init__.py:127, in import_module(name, package)
    [125](file:///C:/Users/TAHAVORM/AppData/Local/miniconda3/envs/ramp/lib/importlib/__init__.py:125)             break
    [126](file:///C:/Users/TAHAVORM/AppData/Local/miniconda3/envs/ramp/lib/importlib/__init__.py:126)         level += 1
--> [127](file:///C:/Users/TAHAVORM/AppData/Local/miniconda3/envs/ramp/lib/importlib/__init__.py:127) return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1030, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1007, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:984, in _find_and_load_unlocked(name, import_)

ModuleNotFoundError: No module named 'ramp/example/input_file_1'


Copy link
Collaborator

@mohammadamint mohammadamint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to add it to the docs API section also, so user can read the function features

@Bachibouzouk
Copy link
Collaborator Author

Bachibouzouk commented May 8, 2024

not sure if it is the correct way or not

This should probably be the path which is not what windows expects, maybe if you provide the full absolute path it works ?

If you look at the first post of this thread, I explain how to test this feature in the terminal as well, can you try this as well?

I think the problematic call happens there:

file_module = importlib.import_module(fname)
maybe you can try to fiddle with it to manage to import any python module (.py file) you create in a folder not within your current directory?

@Bachibouzouk Bachibouzouk force-pushed the fix/convert-old-excel-files branch 2 times, most recently from 755f3ce to ef0d223 Compare May 13, 2024 21:03
@Bachibouzouk Bachibouzouk force-pushed the fix/convert-old-excel-files branch from ef0d223 to aadb838 Compare May 14, 2024 13:56
@Bachibouzouk
Copy link
Collaborator Author

@mohammadamint - I updated the documentation

@s-eckoff did test that it was working on windows, and I tested with a colleague who has windows, it worked

As our tests all passed and I implemented your suggestion I will merge now

@Bachibouzouk Bachibouzouk merged commit ef010ae into joss-paper May 15, 2024
3 checks passed
@Bachibouzouk Bachibouzouk deleted the fix/convert-old-excel-files branch June 24, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants